package com.jinmdz.fmis.mapper.mapper.provider;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;
import com.jinmdz.fmis.mapper.entity.MournCeremonyEntity;

/**
 * 礼厅业务表Provider
 * 
 * @author generator
 * @date 2020-08-23 18:11
 */
public class MournCeremonyProvider {

    /**
     * 增加MournCeremony
     * 
     * @param entity 数据实体
     * @return String
     * @author generator
     * @date 2020-08-23 18:11
     */
    public String insertMournCeremony(@Param("entity") MournCeremonyEntity entity) {
        return new SQL() {
            {
                INSERT_INTO(" mourn_ceremony ");

                if (entity.getDeleted() != null) {
                    VALUES(" deleted ", " #{entity.deleted,jdbcType=TINYINT} ");
                }

                VALUES(" business_code ", " #{entity.businessCode,jdbcType=VARCHAR} ");
                VALUES(" hall_type_code ", " #{entity.hallTypeCode,jdbcType=SMALLINT} ");
                VALUES(" hall_id ", " #{entity.hallId,jdbcType=INTEGER} ");
                VALUES(" appointment_in_time ", " #{entity.appointmentInTime,jdbcType=TIMESTAMP} ");
                VALUES(" appointment_out_time ", " #{entity.appointmentOutTime,jdbcType=TIMESTAMP} ");
                VALUES(" reality_in_time ", " #{entity.realityInTime,jdbcType=TIMESTAMP} ");
                VALUES(" reality_out_time ", " #{entity.realityOutTime,jdbcType=TIMESTAMP} ");
                VALUES(" process_state_code ", " #{entity.processStateCode,jdbcType=TINYINT} ");
                VALUES(" rule_number ", " #{entity.ruleNumber,jdbcType=DECIMAL} ");
                VALUES(" rule_unit ", " #{entity.ruleUnit,jdbcType=VARCHAR} ");
                VALUES(" rule_code ", " #{entity.ruleCode,jdbcType=VARCHAR} ");
                VALUES(" rule_remark ", " #{entity.ruleRemark} ");
                VALUES(" remark ", " #{entity.remark} ");
                VALUES(" business_type ", " #{entity.businessType,jdbcType=VARCHAR} ");
                VALUES(" random_code ", " #{entity.randomCode,jdbcType=VARCHAR} ");
                VALUES(" charge_id ", " #{entity.chargeId,jdbcType=INTEGER} ");
                VALUES(" session_number_id ", " #{entity.sessionNumberId,jdbcType=INTEGER} ");
                VALUES(" couplet_top ", " #{entity.coupletTop,jdbcType=VARCHAR} ");
                VALUES(" couplet_left ", " #{entity.coupletLeft,jdbcType=VARCHAR} ");
                VALUES(" couplet_right ", " #{entity.coupletRight,jdbcType=VARCHAR} ");
                VALUES(" funeral_parlour_code ", " #{entity.funeralParlourCode,jdbcType=VARCHAR} ");
                VALUES(" create_user_id ", " #{entity.createUserId,jdbcType=INTEGER} ");

                if (entity.getUnmodified() != null) {
                    VALUES(" unmodified ", " #{entity.unmodified,jdbcType=TINYINT} ");
                }

                VALUES(" modified_user_id ", " #{entity.modifiedUserId,jdbcType=INTEGER} ");
                VALUES(" version ", " unix_timestamp(now()) ");
            }
        }.toString();
    }

    /**
     * 修改MournCeremony
     * 
     * @param entity 数据实体
     * @return String
     * @author generator
     * @date 2020-08-23 18:11
     */
    public String updateMournCeremony(@Param("entity") MournCeremonyEntity entity) {
        return new SQL() {
            {
                UPDATE(" mourn_ceremony ");

                if (entity.getDeleted() != null) {
                    SET(" deleted = #{entity.deleted,jdbcType=TINYINT} ");
                }

                SET(" business_code = #{entity.businessCode,jdbcType=VARCHAR} ");
                SET(" hall_type_code = #{entity.hallTypeCode,jdbcType=SMALLINT} ");
                SET(" hall_id = #{entity.hallId,jdbcType=INTEGER} ");
                SET(" appointment_in_time = #{entity.appointmentInTime,jdbcType=TIMESTAMP} ");
                SET(" appointment_out_time = #{entity.appointmentOutTime,jdbcType=TIMESTAMP} ");
                SET(" reality_in_time = #{entity.realityInTime,jdbcType=TIMESTAMP} ");
                SET(" reality_out_time = #{entity.realityOutTime,jdbcType=TIMESTAMP} ");
                SET(" process_state_code = #{entity.processStateCode,jdbcType=TINYINT} ");
                SET(" rule_number = #{entity.ruleNumber,jdbcType=DECIMAL} ");
                SET(" rule_unit = #{entity.ruleUnit,jdbcType=VARCHAR} ");
                SET(" rule_code = #{entity.ruleCode,jdbcType=VARCHAR} ");
                SET(" rule_remark = #{entity.ruleRemark} ");
                SET(" remark = #{entity.remark} ");
                SET(" business_type = #{entity.businessType,jdbcType=VARCHAR} ");
                SET(" random_code = #{entity.randomCode,jdbcType=VARCHAR} ");
                SET(" charge_id = #{entity.chargeId,jdbcType=INTEGER} ");
                SET(" session_number_id = #{entity.sessionNumberId,jdbcType=INTEGER} ");
                SET(" couplet_top = #{entity.coupletTop,jdbcType=VARCHAR} ");
                SET(" couplet_left = #{entity.coupletLeft,jdbcType=VARCHAR} ");
                SET(" couplet_right = #{entity.coupletRight,jdbcType=VARCHAR} ");
                SET(" funeral_parlour_code = #{entity.funeralParlourCode,jdbcType=VARCHAR} ");

                if (entity.getUnmodified() != null) {
                    SET(" unmodified = #{entity.unmodified,jdbcType=TINYINT} ");
                }

                SET(" modified_user_id = #{entity.modifiedUserId,jdbcType=INTEGER} ");
                SET(" version = unix_timestamp(now()) ");
                WHERE(" id = #{entity.id,jdbcType=INTEGER} ");
                WHERE(" unmodified = 0 ");
                WHERE(" version = #{entity.version,jdbcType=INTEGER} ");
            }
        }.toString();
    }

    /**
     * 查询MournCeremony列表
     * 
     * @param entity 数据实体
     * @return String
     * @author generator
     * @date 2020-08-23 18:11
     */
    public String listMournCeremony(@Param("entity") MournCeremonyEntity entity) {
        return new SQL() {
            {
                StringBuilder builder = new StringBuilder();
                builder.append(" id,deleted,business_code,hall_type_code,hall_id,appointment_in_time,appointment_out_time,reality_in_time,reality_out_time,process_state_code,rule_number,rule_unit,rule_code,rule_remark,remark,business_type,random_code,charge_id,session_number_id,couplet_top,couplet_left,couplet_right,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version ");
                SELECT(builder.toString());
                FROM(" mourn_ceremony ");

                if (entity.getBusinessCode() != null) {
                    WHERE(" business_code = #{entity.businessCode,jdbcType=VARCHAR} ");
                }

                if (entity.getHallTypeCode() != null) {
                    WHERE(" hall_type_code = #{entity.hallTypeCode,jdbcType=SMALLINT} ");
                }

                if (entity.getHallId() != null) {
                    WHERE(" hall_id = #{entity.hallId,jdbcType=INTEGER} ");
                }

                if (entity.getAppointmentInTime() != null) {
                    WHERE(" appointment_in_time = #{entity.appointmentInTime,jdbcType=TIMESTAMP} ");
                }

                if (entity.getAppointmentOutTime() != null) {
                    WHERE(" appointment_out_time = #{entity.appointmentOutTime,jdbcType=TIMESTAMP} ");
                }

                if (entity.getRealityInTime() != null) {
                    WHERE(" reality_in_time = #{entity.realityInTime,jdbcType=TIMESTAMP} ");
                }

                if (entity.getRealityOutTime() != null) {
                    WHERE(" reality_out_time = #{entity.realityOutTime,jdbcType=TIMESTAMP} ");
                }

                if (entity.getProcessStateCode() != null) {
                    WHERE(" process_state_code = #{entity.processStateCode,jdbcType=TINYINT} ");
                }

                if (entity.getRuleNumber() != null) {
                    WHERE(" rule_number = #{entity.ruleNumber,jdbcType=DECIMAL} ");
                }

                if (entity.getRuleUnit() != null) {
                    WHERE(" rule_unit = #{entity.ruleUnit,jdbcType=VARCHAR} ");
                }

                if (entity.getRuleCode() != null) {
                    WHERE(" rule_code = #{entity.ruleCode,jdbcType=VARCHAR} ");
                }

                if (entity.getRuleRemark() != null) {
                    WHERE(" rule_remark = #{entity.ruleRemark} ");
                }

                if (entity.getRemark() != null) {
                    WHERE(" remark = #{entity.remark} ");
                }

                if (entity.getBusinessType() != null) {
                    WHERE(" business_type = #{entity.businessType,jdbcType=VARCHAR} ");
                }

                if (entity.getRandomCode() != null) {
                    WHERE(" random_code = #{entity.randomCode,jdbcType=VARCHAR} ");
                }

                if (entity.getChargeId() != null) {
                    WHERE(" charge_id = #{entity.chargeId,jdbcType=INTEGER} ");
                }

                if (entity.getSessionNumberId() != null) {
                    WHERE(" session_number_id = #{entity.sessionNumberId,jdbcType=INTEGER} ");
                }

                if (entity.getCoupletTop() != null) {
                    WHERE(" couplet_top = #{entity.coupletTop,jdbcType=VARCHAR} ");
                }

                if (entity.getCoupletLeft() != null) {
                    WHERE(" couplet_left = #{entity.coupletLeft,jdbcType=VARCHAR} ");
                }

                if (entity.getCoupletRight() != null) {
                    WHERE(" couplet_right = #{entity.coupletRight,jdbcType=VARCHAR} ");
                }

                if (entity.getFuneralParlourCode() != null) {
                    WHERE(" funeral_parlour_code = #{entity.funeralParlourCode,jdbcType=VARCHAR} ");
                }

            }
        }.toString();
    }
}